package com.weixin.paleituo.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.adapter.SelectBuildingRecyclerViewAdapter;
import com.weixin.paleituo.base.BaseActivity;
import com.weixin.paleituo.eventbus.SelectHouseEvent;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 选择楼栋
 */

public class SelectBuildingActivity extends BaseActivity {


    @BindView(R.id.iv_back_activity_basepersoninfo)
    ImageView mIvBackActivityBasepersoninfo;
    @BindView(R.id.tv_title_activity_baseperson)
    TextView mTvTitleActivityBaseperson;
    @BindView(R.id.tv_small_title_layout_head)
    TextView mTvSmallTitleLayoutHead;
    @BindView(R.id.rl_head_root_activity_baseperson)
    RelativeLayout mRlHeadRootActivityBaseperson;
    @BindView(R.id.tv_current_location_activity_select_building)
    TextView mTvCurrentLocationActivitySelectBuilding;
    @BindView(R.id.recycle_activity_select_building)
    RecyclerView mRecycleActivitySelectBuilding;
    private SelectBuildingRecyclerViewAdapter mSelectBuildingRecyclerViewAdapter;
    private List<String> mStringList;

    @Override
    protected void initView() {

        setContentView(R.layout.activity_select_building);
    }

    @Override
    protected void initData() {
        super.initData();
        mTvTitleActivityBaseperson.setText("选择楼栋");

        mStringList = new ArrayList<>();
        mStringList.add("金南园   1栋");
        mSelectBuildingRecyclerViewAdapter = new SelectBuildingRecyclerViewAdapter(this, mStringList);
        mRecycleActivitySelectBuilding.setAdapter(mSelectBuildingRecyclerViewAdapter);
        mRecycleActivitySelectBuilding.setItemAnimator(new DefaultItemAnimator());
        mRecycleActivitySelectBuilding.setLayoutManager(new LinearLayoutManager(this));
        mSelectBuildingRecyclerViewAdapter.setOnListener(new SelectBuildingRecyclerViewAdapter.OnListener() {
            @Override
            public void onItemOnClick(int position) {
                EventBus.getDefault().post(new SelectHouseEvent(mStringList.get(position),3));

                SelectHouseNumberActivity.myStartActiviyt(SelectBuildingActivity.this);
            }
        });
    }
    @OnClick(R.id.iv_back_activity_basepersoninfo)
    public void onMIvBackActivityBasepersoninfoClicked() {

        finish();
    }

    public static  void myStartyActvity(Context context){
        Intent intent=new Intent(context,SelectBuildingActivity.class);
        context.startActivity(intent);
    }

}
